package com.hdsx.restful.util;

import java.io.IOException;

import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;

import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier;

/**
 * 专门用于压缩路线空间数据
 * @author wusq
 *
 */
public class LineJSONFormater extends JsonSerializer<Geometry>{

	@Override
	public void serialize(Geometry value, JsonGenerator jgen,SerializerProvider provider) 
			throws IOException, JsonProcessingException {
		
		jgen.writeString(DouglasPeuckerSimplifier.simplify(value, 0.0001d).toString());
	}
}